package com.tutu.elementui.service.impl;

import com.tutu.elementui.entity.Blog;
import com.tutu.elementui.mapper.BlogMapper;
import com.tutu.elementui.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Program: SpringBoot
 * @Description:
 * @Author: JK.TuTu
 * @Create: 2022-11-02 10:20
 **/

@Service
@Transactional
public class BlogServiceImpl implements BlogService {

    @Autowired
    private BlogMapper blogMapper;
    @Override
    public List<Blog> findAll() {
        return blogMapper.findAll();
    }

    /**
     * 保存博客
     *
     * @param blog
     */
    @Override
    public void saveBlog(Blog blog) {
        blogMapper.saveBlog(blog);
    }

    /**
     * 删除博客
     *
     * @param id
     */
    @Override
    public void deleteBlog(Integer id) {
        blogMapper.deleteBlog(id);
    }

    /**
     * 根据id查询博客
     *
     * @param id
     * @return
     */
    @Override
    public Blog findBlogById(int id) {
        return blogMapper.findBlogById(id);
    }

    /**
     * 修改blog
     *
     * @param blog
     */
    @Override
    public void updateBlog(Blog blog) {
       blogMapper.updateBlog(blog);
    }

    /**
     * 分页查询
     *
     * @param page
     * @param pageSize
     * @return
     */
    @Override
    public List<Blog> searchForPage(int page, int pageSize) {
        return blogMapper.searchForPage(page,pageSize);
    }

    /**
     * 查询总条数
     *
     * @return
     */
    @Override
    public int findTotal() {
        return blogMapper.findTotal();
    }
}
